/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.javscaz.javscaztools.tablas;

import java.awt.Component;
import java.util.EventObject;
import javax.swing.JEditorPane;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextArea;
import javax.swing.event.CellEditorListener;
import javax.swing.table.TableCellEditor;

/**
 *
 * @author avbravo
 */
public class CustomEditor implements TableCellEditor {

    JTextArea textArea;
    JScrollPane scrollPane;
 JEditorPane editor = new JEditorPane();
    public CustomEditor() {
       
        editor.setContentType("text/html");
        textArea = new JTextArea();
        scrollPane = new JScrollPane(textArea);
//          scrollPane = new JScrollPane(editor);
    }

    public Component getTableCellEditorComponent(JTable table,
            Object value,
            boolean isSelected,
            int row, int column) {
        textArea.setText((String) value);
          textArea.setWrapStyleWord(true);  
       textArea.setLineWrap(true);  
//         editor.setText((String) value);
        return scrollPane;
    }

    @Override
    public void addCellEditorListener(CellEditorListener l) {
    }

    public void cancelCellEditing() {
    }

    public Object getCellEditorValue() {
        return textArea.getText();
    }

    @Override
    public boolean isCellEditable(EventObject anEvent) {
        return true;
    }

    @Override
    public void removeCellEditorListener(CellEditorListener l) {
    }

    @Override
    public boolean shouldSelectCell(EventObject anEvent) {
        return true;
    }

    public boolean stopCellEditing() {
        return true;
    }
}
